/**
 * 您的公司.com
 * Copyright (c) 2018-2018 All Rights Reserved.
 */
package com.mei.demo.Thread;

/**
 *
 * @author mei.xiaoliang@qq.com
 */
public class Demo6 {

    public static void main(String[] args) {
        Thread mainThread = Thread.currentThread();
        for (int j = 0; j < 4; j++) {
            Thread t1 = new Thread(() -> {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName() + " " + i);
                    if (i == 10) {
                        System.out.println("\n" + Thread.currentThread().getName() + " 让主线程先来！\n");
                        try {
                            mainThread.join();
                        } catch (InterruptedException e) {

                        }
                    }
                }
            });
            t1.start();
        }
        for (int i = 0; i < 50; i++) {
            System.out.println("主线程 " + i);
        }
    }
}
